//  BoinkSpaceView
//
//  a subclass of BoinkView that adds a space view subview for special effect
//
//  You may freely copy, distribute, and reuse the code in this example.
//  NeXT disclaims any warranty of any kind, expressed or  implied, as to its
//  fitness for any particular use.

#import "BoinkSpaceView.h"
#import "Thinker.h"
#import <appkit/Application.h>
#import <dpsclient/wraps.h>

@implementation BoinkSpaceView

- oneStep
{
	// this is weird but efficient - focus is locked on this View, and
	// spaceview goes ahead and draws on it.  It's like subviews, only
	// faster because all coordinate systems are kept the same...

	[super oneStep];

	avoid.origin = redrawTo;
	[mySpaceView setVoidRect:&avoid];
	[mySpaceView oneStep];

	return self;
}

- initFrame:(const NXRect *)frameRect
{
	[super initFrame:frameRect];
	
	mySpaceView = [[SpaceView alloc] initFrame:frameRect];
	[self setAccel:-1.4];
	
	[self newViewSize];
	avoid.size.width = avoid.size.height = 100;
	return self;
}

- sizeTo:(NXCoord)width :(NXCoord)height
{
	[super sizeTo:width :height];
	[mySpaceView sizeTo:width :height];
	[self newViewSize];
	return self;
}

- drawSelf:(const NXRect *)rects :(int)rectCount
{
	if (!rects || !rectCount) return self;
	
	PSsetgray(0);
	//NXRectFill(rects);

	return self;
}

- (float) getXspeed
{
	return randBetween(4, 6.5);
}

- (const char *)windowTitle
{
	return "BoinkSpace";
}

- newViewSize
{
	[super newViewSize];
	nvert =	nhoriz = 0;
	return self;
}

- didLockFocus
{
	[mySpaceView didLockFocus];
	return self;
}

@end
